package mvc_generator.generator.car.struts;

import com.google.common.base.Objects;
import mvc_generator.generator.MVCGeneratorGeneratorUtils;
import mvc_generator.generator.car.struts.StrutsGenerator;
import mvc_generator.mVCGenerator.ArithmeticExpression;
import mvc_generator.mVCGenerator.ArithmeticPrimitive;
import mvc_generator.mVCGenerator.ArithmeticVariable;
import mvc_generator.mVCGenerator.AssignedField;
import mvc_generator.mVCGenerator.BooleanExpression;
import mvc_generator.mVCGenerator.BooleanPrimitive;
import mvc_generator.mVCGenerator.BooleanVariable;
import mvc_generator.mVCGenerator.Condition;
import mvc_generator.mVCGenerator.Controller;
import mvc_generator.mVCGenerator.DoubleExpression;
import mvc_generator.mVCGenerator.Expression;
import mvc_generator.mVCGenerator.Form;
import mvc_generator.mVCGenerator.FormValidation;
import mvc_generator.mVCGenerator.IntegerExpression;
import mvc_generator.mVCGenerator.ModelMVC;
import mvc_generator.mVCGenerator.ParenthesizedArithmeticExpression;
import mvc_generator.mVCGenerator.ParenthesizedBooleanExpression;
import mvc_generator.mVCGenerator.SimpleType;
import mvc_generator.mVCGenerator.StringExpression;
import mvc_generator.mVCGenerator.StringLengthExpression;
import mvc_generator.mVCGenerator.View;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.StringExtensions;

@SuppressWarnings("all")
public class ValidationFormGenerator {
  private StrutsGenerator g;
  
  public ValidationFormGenerator(final StrutsGenerator gen) {
    this.g = gen;
  }
  
  public void generate(final Form form, final IFileSystemAccess fsa) {
    ModelMVC modelMVCContainer = MVCGeneratorGeneratorUtils.findModelMVCContainer(form);
    StringConcatenation _builder = new StringConcatenation();
    CharSequence validationFormContent = _builder;
    StringConcatenation _builder_1 = new StringConcatenation();
    CharSequence fieldDeclarationContent = _builder_1;
    StringConcatenation _builder_2 = new StringConcatenation();
    CharSequence getterContent = _builder_2;
    StringConcatenation _builder_3 = new StringConcatenation();
    CharSequence setterContent = _builder_3;
    StringConcatenation _builder_4 = new StringConcatenation();
    _builder_4.append("private static final long serialVersionUID = 1L;");
    _builder_4.newLine();
    {
      EList<AssignedField> _assignedFields = form.getAssignedFields();
      for(final AssignedField assignedField : _assignedFields) {
        _builder_4.append("\t");
        _builder_4.append("private ");
        SimpleType _simpleTypeOfAssignement = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField);
        String _stringRepresentation = _simpleTypeOfAssignement.getStringRepresentation();
        _builder_4.append(_stringRepresentation, "	");
        _builder_4.append(" ");
        String _fieldName = assignedField.getFieldName();
        _builder_4.append(_fieldName, "	");
        _builder_4.append(" = ");
        SimpleType _simpleTypeOfAssignement_1 = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField);
        String _initialValue = MVCGeneratorGeneratorUtils.getInitialValue(_simpleTypeOfAssignement_1);
        _builder_4.append(_initialValue, "	");
        _builder_4.append(";");
        _builder_4.newLineIfNotEmpty();
      }
    }
    fieldDeclarationContent = _builder_4;
    StringConcatenation _builder_5 = new StringConcatenation();
    {
      EList<AssignedField> _assignedFields_1 = form.getAssignedFields();
      for(final AssignedField assignedField_1 : _assignedFields_1) {
        _builder_5.append("/**");
        _builder_5.newLine();
        _builder_5.append(" ");
        _builder_5.append("* @return ");
        String _fieldName_1 = assignedField_1.getFieldName();
        _builder_5.append(_fieldName_1, " ");
        _builder_5.newLineIfNotEmpty();
        _builder_5.append(" ");
        _builder_5.append("*/");
        _builder_5.newLine();
        _builder_5.append("public ");
        SimpleType _simpleTypeOfAssignement_2 = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField_1);
        String _stringRepresentation_1 = _simpleTypeOfAssignement_2.getStringRepresentation();
        _builder_5.append(_stringRepresentation_1, "");
        _builder_5.append(" get");
        String _fieldName_2 = assignedField_1.getFieldName();
        String _firstUpper = StringExtensions.toFirstUpper(_fieldName_2);
        _builder_5.append(_firstUpper, "");
        _builder_5.append("() {");
        _builder_5.newLineIfNotEmpty();
        _builder_5.append("\t");
        _builder_5.append("return ");
        String _fieldName_3 = assignedField_1.getFieldName();
        _builder_5.append(_fieldName_3, "	");
        _builder_5.append(";");
        _builder_5.newLineIfNotEmpty();
        _builder_5.append("}");
        _builder_5.newLine();
      }
    }
    getterContent = _builder_5;
    StringConcatenation _builder_6 = new StringConcatenation();
    {
      EList<AssignedField> _assignedFields_2 = form.getAssignedFields();
      for(final AssignedField assignedField_2 : _assignedFields_2) {
        _builder_6.append("/**");
        _builder_6.newLine();
        _builder_6.append(" ");
        _builder_6.append("* @param ");
        SimpleType _simpleTypeOfAssignement_3 = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField_2);
        String _stringRepresentation_2 = _simpleTypeOfAssignement_3.getStringRepresentation();
        _builder_6.append(_stringRepresentation_2, " ");
        _builder_6.newLineIfNotEmpty();
        _builder_6.append(" ");
        _builder_6.append("*            Sets the ");
        String _fieldName_4 = assignedField_2.getFieldName();
        _builder_6.append(_fieldName_4, " ");
        _builder_6.newLineIfNotEmpty();
        _builder_6.append(" ");
        _builder_6.append("*/");
        _builder_6.newLine();
        _builder_6.append("public void set");
        String _fieldName_5 = assignedField_2.getFieldName();
        String _firstUpper_1 = StringExtensions.toFirstUpper(_fieldName_5);
        _builder_6.append(_firstUpper_1, "");
        _builder_6.append("(");
        SimpleType _simpleTypeOfAssignement_4 = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField_2);
        String _stringRepresentation_3 = _simpleTypeOfAssignement_4.getStringRepresentation();
        _builder_6.append(_stringRepresentation_3, "");
        _builder_6.append(" value) {");
        _builder_6.newLineIfNotEmpty();
        _builder_6.append("\t");
        String _fieldName_6 = assignedField_2.getFieldName();
        _builder_6.append(_fieldName_6, "	");
        _builder_6.append(" = value»;");
        _builder_6.newLineIfNotEmpty();
        _builder_6.append("}");
        _builder_6.newLine();
      }
    }
    setterContent = _builder_6;
    StringConcatenation _builder_7 = new StringConcatenation();
    _builder_7.append("\t\t");
    _builder_7.append("package actionForm;");
    _builder_7.newLine();
    _builder_7.newLine();
    _builder_7.append("import javax.servlet.http.HttpServletRequest;");
    _builder_7.newLine();
    _builder_7.append("import org.apache.struts.action.ActionErrors;");
    _builder_7.newLine();
    _builder_7.append("import org.apache.struts.action.ActionForm;");
    _builder_7.newLine();
    _builder_7.append("import org.apache.struts.action.ActionMapping;");
    _builder_7.newLine();
    _builder_7.append("import org.apache.struts.action.ActionMessage;");
    _builder_7.newLine();
    _builder_7.newLine();
    _builder_7.append("public class ");
    String _name = form.getName();
    _builder_7.append(_name, "");
    _builder_7.append("ValidationForm extends ActionForm {");
    _builder_7.newLineIfNotEmpty();
    _builder_7.newLine();
    _builder_7.append("\t");
    _builder_7.append(fieldDeclarationContent, "	");
    _builder_7.newLineIfNotEmpty();
    _builder_7.append("\t");
    _builder_7.append(getterContent, "	");
    _builder_7.newLineIfNotEmpty();
    _builder_7.append("\t");
    _builder_7.newLine();
    _builder_7.append("\t");
    _builder_7.append(setterContent, "	");
    _builder_7.newLineIfNotEmpty();
    _builder_7.newLine();
    _builder_7.append("\t");
    _builder_7.append("public void reset(ActionMapping mapping, HttpServletRequest request) {");
    _builder_7.newLine();
    {
      EList<AssignedField> _assignedFields_3 = form.getAssignedFields();
      for(final AssignedField assignedField_3 : _assignedFields_3) {
        _builder_7.append("\t\t");
        _builder_7.append("this.");
        String _fieldName_7 = assignedField_3.getFieldName();
        _builder_7.append(_fieldName_7, "		");
        _builder_7.append(" = ");
        SimpleType _simpleTypeOfAssignement_5 = MVCGeneratorGeneratorUtils.getSimpleTypeOfAssignement(assignedField_3);
        String _initialValue_1 = MVCGeneratorGeneratorUtils.getInitialValue(_simpleTypeOfAssignement_5);
        _builder_7.append(_initialValue_1, "		");
        _builder_7.append(";");
        _builder_7.newLineIfNotEmpty();
      }
    }
    _builder_7.append("\t");
    _builder_7.append("}");
    _builder_7.newLine();
    _builder_7.newLine();
    _builder_7.append("\t");
    _builder_7.append("public ActionErrors validate(ActionMapping mapping,");
    _builder_7.newLine();
    _builder_7.append("\t\t\t");
    _builder_7.append("HttpServletRequest request) {");
    _builder_7.newLine();
    _builder_7.append("\t\t");
    _builder_7.append("ActionErrors errors = new ActionErrors();");
    _builder_7.newLine();
    _builder_7.append("\t\t");
    _builder_7.newLine();
    _builder_7.append("\t\t");
    FormValidation _validator = MVCGeneratorGeneratorUtils.getValidator(form);
    CharSequence _generateConditions = this.generateConditions(_validator);
    _builder_7.append(_generateConditions, "		");
    _builder_7.newLineIfNotEmpty();
    _builder_7.append("\t\t");
    _builder_7.newLine();
    _builder_7.append("\t\t");
    _builder_7.append("return errors;");
    _builder_7.newLine();
    _builder_7.append("\t");
    _builder_7.append("}");
    _builder_7.newLine();
    _builder_7.append("}");
    _builder_7.newLine();
    validationFormContent = _builder_7;
    EList<AssignedField> _assignedFields_4 = form.getAssignedFields();
    for (final AssignedField assignedField_4 : _assignedFields_4) {
      String _name_1 = form.getName();
      String _plus = (_name_1 + ".");
      String _fieldName_8 = assignedField_4.getFieldName();
      String _plus_1 = (_plus + _fieldName_8);
      String _plus_2 = (_plus_1 + ".error.required= ");
      String _name_2 = form.getName();
      String _plus_3 = (_plus_2 + _name_2);
      String _plus_4 = (_plus_3 + "\'s ");
      String _fieldName_9 = assignedField_4.getFieldName();
      String _plus_5 = (_plus_4 + _fieldName_9);
      String _plus_6 = (_plus_5 + " is required");
      this.g.addLineToResourcesContentFile(_plus_6);
    }
    String _name_3 = modelMVCContainer.getName();
    String _plus_7 = (_name_3 + "Struts");
    String _plus_8 = (_plus_7 + StrutsGenerator.actionFormPath);
    String _name_4 = form.getName();
    String _plus_9 = (_plus_8 + _name_4);
    String _plus_10 = (_plus_9 + "ValidationForm.java");
    fsa.generateFile(_plus_10, validationFormContent);
  }
  
  private CharSequence generateConditions(final FormValidation fv) {
    String prefix = "";
    int condNumber = 1;
    Controller _findContainer = MVCGeneratorGeneratorUtils.<Controller>findContainer(fv, Controller.class);
    View _controlledView = _findContainer.getControlledView();
    String _name = _controlledView.getName();
    String _plus = (prefix + _name);
    String _plus_1 = (_plus + ".");
    prefix = _plus_1;
    FormValidation _findContainer_1 = MVCGeneratorGeneratorUtils.<FormValidation>findContainer(fv, FormValidation.class);
    String _validatedFormName = _findContainer_1.getValidatedFormName();
    String _plus_2 = (prefix + _validatedFormName);
    prefix = _plus_2;
    StringConcatenation _builder = new StringConcatenation();
    {
      EList<Condition> _conditions = fv.getConditions();
      int _length = ((Object[])Conversions.unwrapArray(_conditions, Object.class)).length;
      boolean _greaterThan = (_length > 0);
      if (_greaterThan) {
        _builder.append("{");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("Boolean success = true;");
        _builder.newLine();
        _builder.append("\t");
        _builder.newLine();
        {
          EList<Condition> _conditions_1 = fv.getConditions();
          for(final Condition condition : _conditions_1) {
            _builder.append("\t");
            _builder.append("success = success && (");
            Expression _condValue = condition.getCondValue();
            CharSequence _generate = this.generate(_condValue);
            _builder.append(_generate, "	");
            _builder.append(");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("if(success == false){");
            _builder.newLine();
            _builder.append("\t");
            _builder.append("\t");
            _builder.append("errors.add(ActionMessages.GLOBAL_MESSAGE, \"");
            String _firstLower = StringExtensions.toFirstLower(prefix);
            _builder.append(_firstLower, "		");
            _builder.append(".cond");
            _builder.append(condNumber, "		");
            _builder.append(".error\");");
            _builder.newLineIfNotEmpty();
            _builder.append("\t");
            _builder.append("}");
            _builder.newLine();
            {
              String _errorDescription = condition.getErrorDescription();
              boolean _notEquals = (!Objects.equal(_errorDescription, null));
              if (_notEquals) {
                _builder.append("\t");
                String _firstLower_1 = StringExtensions.toFirstLower(prefix);
                String _plus_3 = (_firstLower_1 + ".cond");
                String _plus_4 = (_plus_3 + Integer.valueOf(condNumber));
                String _plus_5 = (_plus_4 + ".error=\"");
                String _errorDescription_1 = condition.getErrorDescription();
                String _plus_6 = (_plus_5 + _errorDescription_1);
                String _plus_7 = (_plus_6 + "\"");
                this.g.addLineToResourcesContentFile(_plus_7);
                _builder.newLineIfNotEmpty();
              } else {
                _builder.append("\t");
                String _firstLower_2 = StringExtensions.toFirstLower(prefix);
                String _plus_8 = (_firstLower_2 + ".cond");
                String _plus_9 = (_plus_8 + Integer.valueOf(condNumber));
                String _plus_10 = (_plus_9 + ".error=\"An error occur.\"");
                this.g.addLineToResourcesContentFile(_plus_10);
                _builder.newLineIfNotEmpty();
              }
            }
            _builder.append("\t");
            int _plus_11 = (condNumber + 1);
            int _condNumber = condNumber = _plus_11;
            MVCGeneratorGeneratorUtils.toVoidExpr(Integer.valueOf(_condNumber));
            _builder.newLineIfNotEmpty();
          }
        }
        _builder.append("}");
        _builder.newLine();
      }
    }
    CharSequence result = _builder;
    return result;
  }
  
  private CharSequence generate(final Expression expression) {
    CharSequence _xblockexpression = null;
    {
      StringConcatenation _builder = new StringConcatenation();
      CharSequence result = _builder;
      CharSequence _xifexpression = null;
      if ((expression instanceof BooleanExpression)) {
        CharSequence _generate = this.generate(((BooleanExpression) expression));
        CharSequence _result = result = _generate;
        _xifexpression = _result;
      } else {
        CharSequence _xifexpression_1 = null;
        if ((expression instanceof ArithmeticExpression)) {
          CharSequence _generate_1 = this.generate(((ArithmeticExpression) expression));
          CharSequence _result_1 = result = _generate_1;
          _xifexpression_1 = _result_1;
        } else {
          StringConcatenation _builder_1 = new StringConcatenation();
          _builder_1.append("@Auto_Generated: ");
          Class<? extends Expression> _class = expression.getClass();
          String _name = _class.getName();
          _builder_1.append(_name, "");
          _builder_1.append(" is not a handled expression.");
          CharSequence _result_2 = result = _builder_1;
          _xifexpression_1 = _result_2;
        }
        _xifexpression = _xifexpression_1;
      }
      _xblockexpression = (_xifexpression);
    }
    return _xblockexpression;
  }
  
  private CharSequence generate(final BooleanExpression booleanExpression) {
    StringConcatenation _builder = new StringConcatenation();
    CharSequence result = _builder;
    EObject _op1 = booleanExpression.getOp1();
    if ((_op1 instanceof BooleanVariable)) {
      EObject _op1_1 = booleanExpression.getOp1();
      CharSequence _generate = this.generate(((BooleanVariable) _op1_1));
      result = _generate;
    } else {
      EObject _op1_2 = booleanExpression.getOp1();
      if ((_op1_2 instanceof BooleanPrimitive)) {
        EObject _op1_3 = booleanExpression.getOp1();
        CharSequence _generate_1 = this.generate(((BooleanPrimitive) _op1_3));
        result = _generate_1;
      } else {
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("@AutoGenerated_Error: ");
        EObject _op1_4 = booleanExpression.getOp1();
        Class<? extends EObject> _class = _op1_4.getClass();
        String _name = _class.getName();
        _builder_1.append(_name, "");
        _builder_1.append(" is not a handled expression.");
        result = _builder_1;
      }
    }
    String _symbol = booleanExpression.getSymbol();
    boolean _notEquals = (!Objects.equal(_symbol, null));
    if (_notEquals) {
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append(" ");
      String _symbol_1 = booleanExpression.getSymbol();
      _builder_2.append(_symbol_1, " ");
      _builder_2.append(" ");
      String _plus = (result + _builder_2.toString());
      result = _plus;
      EObject _op2 = booleanExpression.getOp2();
      if ((_op2 instanceof BooleanVariable)) {
        StringConcatenation _builder_3 = new StringConcatenation();
        EObject _op2_1 = booleanExpression.getOp2();
        CharSequence _generate_2 = this.generate(((BooleanVariable) _op2_1));
        _builder_3.append(_generate_2, "");
        String _plus_1 = (result + _builder_3.toString());
        result = _plus_1;
      } else {
        EObject _op2_2 = booleanExpression.getOp2();
        if ((_op2_2 instanceof BooleanPrimitive)) {
          StringConcatenation _builder_4 = new StringConcatenation();
          EObject _op2_3 = booleanExpression.getOp2();
          CharSequence _generate_3 = this.generate(((BooleanPrimitive) _op2_3));
          _builder_4.append(_generate_3, "");
          String _plus_2 = (result + _builder_4.toString());
          result = _plus_2;
        } else {
          EObject _op2_4 = booleanExpression.getOp2();
          if ((_op2_4 instanceof ParenthesizedBooleanExpression)) {
            StringConcatenation _builder_5 = new StringConcatenation();
            EObject _op2_5 = booleanExpression.getOp2();
            CharSequence _generate_4 = this.generate(((ParenthesizedBooleanExpression) _op2_5));
            _builder_5.append(_generate_4, "");
            String _plus_3 = (result + _builder_5.toString());
            result = _plus_3;
          } else {
            StringConcatenation _builder_6 = new StringConcatenation();
            _builder_6.append("@AutoGenerated_Error: ");
            EObject _op2_6 = booleanExpression.getOp2();
            Class<? extends EObject> _class_1 = _op2_6.getClass();
            String _name_1 = _class_1.getName();
            _builder_6.append(_name_1, "");
            _builder_6.append(" is not a handled expression.");
            result = _builder_6;
          }
        }
      }
    }
    return result;
  }
  
  private CharSequence generate(final ArithmeticExpression arithmeticExpression) {
    StringConcatenation _builder = new StringConcatenation();
    CharSequence result = _builder;
    EObject _op1 = arithmeticExpression.getOp1();
    if ((_op1 instanceof ArithmeticVariable)) {
      EObject _op1_1 = arithmeticExpression.getOp1();
      CharSequence _generate = this.generate(((ArithmeticVariable) _op1_1));
      result = _generate;
    } else {
      EObject _op1_2 = arithmeticExpression.getOp1();
      if ((_op1_2 instanceof ArithmeticPrimitive)) {
        EObject _op1_3 = arithmeticExpression.getOp1();
        CharSequence _generate_1 = this.generate(((ArithmeticPrimitive) _op1_3));
        result = _generate_1;
      } else {
        EObject _op1_4 = arithmeticExpression.getOp1();
        if ((_op1_4 instanceof StringLengthExpression)) {
          EObject _op1_5 = arithmeticExpression.getOp1();
          CharSequence _generate_2 = this.generate(((StringLengthExpression) _op1_5));
          result = _generate_2;
        } else {
          StringConcatenation _builder_1 = new StringConcatenation();
          _builder_1.append("@AutoGenerated_Error: ");
          EObject _op1_6 = arithmeticExpression.getOp1();
          Class<? extends EObject> _class = _op1_6.getClass();
          String _name = _class.getName();
          _builder_1.append(_name, "");
          _builder_1.append(" is not a handled expression.");
          result = _builder_1;
        }
      }
    }
    String _symbol = arithmeticExpression.getSymbol();
    boolean _notEquals = (!Objects.equal(_symbol, null));
    if (_notEquals) {
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.append(" ");
      String _symbol_1 = arithmeticExpression.getSymbol();
      _builder_2.append(_symbol_1, " ");
      _builder_2.append(" ");
      String _plus = (result + _builder_2.toString());
      result = _plus;
      EObject _op2 = arithmeticExpression.getOp2();
      if ((_op2 instanceof ArithmeticVariable)) {
        StringConcatenation _builder_3 = new StringConcatenation();
        EObject _op2_1 = arithmeticExpression.getOp2();
        CharSequence _generate_3 = this.generate(((ArithmeticVariable) _op2_1));
        _builder_3.append(_generate_3, "");
        String _plus_1 = (result + _builder_3.toString());
        result = _plus_1;
      } else {
        EObject _op2_2 = arithmeticExpression.getOp2();
        if ((_op2_2 instanceof ArithmeticPrimitive)) {
          StringConcatenation _builder_4 = new StringConcatenation();
          EObject _op2_3 = arithmeticExpression.getOp2();
          CharSequence _generate_4 = this.generate(((ArithmeticPrimitive) _op2_3));
          _builder_4.append(_generate_4, "");
          String _plus_2 = (result + _builder_4.toString());
          result = _plus_2;
        } else {
          EObject _op1_7 = arithmeticExpression.getOp1();
          if ((_op1_7 instanceof StringLengthExpression)) {
            StringConcatenation _builder_5 = new StringConcatenation();
            EObject _op1_8 = arithmeticExpression.getOp1();
            CharSequence _generate_5 = this.generate(((StringLengthExpression) _op1_8));
            _builder_5.append(_generate_5, "");
            String _plus_3 = (result + _builder_5.toString());
            result = _plus_3;
          } else {
            EObject _op2_4 = arithmeticExpression.getOp2();
            if ((_op2_4 instanceof ParenthesizedArithmeticExpression)) {
              StringConcatenation _builder_6 = new StringConcatenation();
              EObject _op2_5 = arithmeticExpression.getOp2();
              CharSequence _generate_6 = this.generate(((ParenthesizedArithmeticExpression) _op2_5));
              _builder_6.append(_generate_6, "");
              String _plus_4 = (result + _builder_6.toString());
              result = _plus_4;
            } else {
              StringConcatenation _builder_7 = new StringConcatenation();
              _builder_7.append("@AutoGenerated_Error: ");
              EObject _op2_6 = arithmeticExpression.getOp2();
              Class<? extends EObject> _class_1 = _op2_6.getClass();
              String _name_1 = _class_1.getName();
              _builder_7.append(_name_1, "");
              _builder_7.append(" is not a handled expression.");
              result = _builder_7;
            }
          }
        }
      }
    }
    return result;
  }
  
  private CharSequence generate(final ArithmeticVariable arithmeticVariable) {
    StringConcatenation _builder = new StringConcatenation();
    String _refer = arithmeticVariable.getRefer();
    _builder.append(_refer, "");
    return _builder;
  }
  
  private CharSequence generate(final StringLengthExpression stringLengthExpression) {
    StringConcatenation _builder = new StringConcatenation();
    String result = _builder.toString();
    EObject _expression = stringLengthExpression.getExpression();
    if ((_expression instanceof StringExpression)) {
      StringConcatenation _builder_1 = new StringConcatenation();
      _builder_1.append("\"");
      EObject _expression_1 = stringLengthExpression.getExpression();
      String _value = ((StringExpression) _expression_1).getValue();
      _builder_1.append(_value, "");
      _builder_1.append("\".length()");
      result = _builder_1.toString();
    } else {
      EObject _expression_2 = stringLengthExpression.getExpression();
      if ((_expression_2 instanceof ArithmeticVariable)) {
        StringConcatenation _builder_2 = new StringConcatenation();
        EObject _expression_3 = stringLengthExpression.getExpression();
        String _refer = ((ArithmeticVariable) _expression_3).getRefer();
        _builder_2.append(_refer, "");
        _builder_2.append(".length()");
        result = _builder_2.toString();
      }
    }
    return result;
  }
  
  private CharSequence generate(final ArithmeticPrimitive arithmeticPrimitive) {
    CharSequence _xifexpression = null;
    if ((arithmeticPrimitive instanceof IntegerExpression)) {
      StringConcatenation _builder = new StringConcatenation();
      int _value = ((IntegerExpression) arithmeticPrimitive).getValue();
      _builder.append(_value, "");
      _xifexpression = _builder;
    } else {
      CharSequence _xifexpression_1 = null;
      if ((arithmeticPrimitive instanceof DoubleExpression)) {
        StringConcatenation _builder_1 = new StringConcatenation();
        int _value_1 = ((DoubleExpression) arithmeticPrimitive).getValue();
        _builder_1.append(_value_1, "");
        _builder_1.append(".");
        int _decimalValue = ((DoubleExpression) arithmeticPrimitive).getDecimalValue();
        _builder_1.append(_decimalValue, "");
        _xifexpression_1 = _builder_1;
      } else {
        CharSequence _xifexpression_2 = null;
        if ((arithmeticPrimitive instanceof StringExpression)) {
          StringConcatenation _builder_2 = new StringConcatenation();
          _builder_2.append("\"");
          String _value_2 = ((StringExpression) arithmeticPrimitive).getValue();
          _builder_2.append(_value_2, "");
          _builder_2.append("\"");
          _xifexpression_2 = _builder_2;
        } else {
          StringConcatenation _builder_3 = new StringConcatenation();
          _builder_3.append("@AutoGenerated_Error: ");
          Class<? extends ArithmeticPrimitive> _class = arithmeticPrimitive.getClass();
          String _name = _class.getName();
          _builder_3.append(_name, "");
          _builder_3.append(" is not a handled ArithmeticPrimitive.");
          _xifexpression_2 = _builder_3;
        }
        _xifexpression_1 = _xifexpression_2;
      }
      _xifexpression = _xifexpression_1;
    }
    return _xifexpression;
  }
  
  private CharSequence generate(final ParenthesizedArithmeticExpression parenthesizedArithmeticExpression) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("(");
    ArithmeticExpression _expression = parenthesizedArithmeticExpression.getExpression();
    CharSequence _generate = this.generate(_expression);
    _builder.append(_generate, "");
    _builder.append(")");
    return _builder;
  }
  
  private CharSequence generate(final BooleanVariable booleanVariable) {
    StringConcatenation _builder = new StringConcatenation();
    String _refer = booleanVariable.getRefer();
    _builder.append(_refer, "");
    return _builder;
  }
  
  private CharSequence generate(final BooleanPrimitive booleanPrimitive) {
    StringConcatenation _builder = new StringConcatenation();
    String _value = booleanPrimitive.getValue();
    _builder.append(_value, "");
    return _builder;
  }
  
  private CharSequence generate(final ParenthesizedBooleanExpression parenthesizedBooleanExpression) {
    StringConcatenation _builder = new StringConcatenation();
    BooleanExpression _expression = parenthesizedBooleanExpression.getExpression();
    CharSequence _generate = this.generate(_expression);
    _builder.append(_generate, "");
    return _builder;
  }
}
